package com.xfatm.util.typecase;

import java.math.BigDecimal;

public class ToIntegerTypeCase {

    public class ObjectToInt implements TypeCase{
        @Override
        public Integer typeCase(Object o) {
            if(o==null){
                return 0;
            }
            return Integer.parseInt(o.toString());
        }
    }

    public class ObjectToInteger implements TypeCase{
        @Override
        public Integer typeCase(Object o) {
            if(o==null){
                return null;
            }
            return Integer.parseInt(o.toString());
        }
    }

    public class BigDecimalToInteger implements TypeCase{
        @Override
        public Integer typeCase(Object o) {
            if(o==null){
                return null;
            }
            return ((BigDecimal)o).intValue();
        }
    }

    public class BigDecimalToInt implements TypeCase{
        @Override
        public Integer typeCase(Object o) {
            if(o==null){
                return 0;
            }
            return ((BigDecimal)o).intValue();
        }
    }
}
